Using the Len() function to check for an empty string is about 30 percent faster than using the <> or = sign:
If strTest <> "" Then
...
End If
The following code does the same thing but is more efficient:
If Len(strTest) Then
...
End If
This second code is faster because it doesnt take as much time to count the number of bytes that make up a string as it does to compare every character in one string against every character in another string. Even when the string is blank, the <> operator has to still do a comparison. In addition, the not equal (<>) sign is not a very efficient operator. Of course, I think you lose a little readability by using the Len() function.
Don't Compare Variables for Not Equal to Zero
If youre checking a numeric value against 0, its faster just to check the variable with an If statement:
If intTest <> 0 Then
...
End If
The following statement is equivalent to the first, but it runs faster (you will lose some readability, however):
If intTest Then ... End If
Use For. . .Each Instead of For. . .Next
To loop through a collection of objects, use the For...Each construct instead of the For...Next looping construct:
For lngLoop = 0 To 10000
For intLoop = 0 To Forms.Count - 1